//
//  HBSetPushAccountManager.m
//  HuoBao
//
//  Created by chaiyanan on 15/12/23.
//  Copyright © 2015年 jinxin. All rights reserved.
//

#import "HBSetPushAccountManager.h"
#import "HBSetPushAccountParam.h"
#import "HBSetPushAccountParser.h"

#import "HBGetUserInfoManager.h"

@implementation HBSetPushAccountManager

+(void)requestToSetPushAccountWithResult:(void (^)(BOOL, NSString *, NSError *))result
{
    HBSetPushAccountParam *param = [[HBSetPushAccountParam alloc]init];
    param.uid = [HBLoginManager sharedHBLoginManager].currentUserInfo.uid;
    param.token = [HBLoginManager sharedHBLoginManager].currentUserInfo.token;
    param.baiduUserId = [[NSUserDefaults standardUserDefaults]objectForKey:Key_YunUserid];
    param.baiduChannelId = [[NSUserDefaults standardUserDefaults]objectForKey:Key_YunChannelid];
    HBSetPushAccountParser *parser = [[HBSetPushAccountParser alloc]init];
    [NetCenter postDataFromURL:Method_setPushAccount
                       params:param
                       parser:parser
                       result:^(ParserResult *myResult)
     {
         if (myResult.code ==0 )
         {
             [HBGetUserInfoManager requestToGetUserInfoWithResult:^(BOOL isSuccess, NSString *msg, NSError *error) {
                 
             }];
             
             if (result)
             {
                 result(YES, myResult.message, nil);
             }
         }
         else
         {
             if (result)
             {
                 result(NO, myResult.message, nil);
             }
         }
         
     } failure:^(NSError *error)
     {
         if (result)
         {
             result(NO, @"", error);
         }
     }];
}

@end
